
import java.awt.FlowLayout;
import java.util.List;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
/**
 * JTable显示数据
 * https://blog.csdn.net/qq_44716544/article/details/102828692?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.channel_param
 */
public class JTableFrameTest extends JFrame{
    public JTableFrameTest(String title) {
        super(title);
        init();
    }
    public void init(){
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setLayout(new FlowLayout());
        List<String> list=new ArrayList<String>();
        for(int i=0;i<5;i++){
           list.add("表格"+i);
        }
        Vector<String> columnNames=new Vector<String>();//存放列名
        columnNames.add("学号");
        columnNames.add("姓名");
        Vector<Vector> rowData=new Vector<Vector>();//存放行数据
        Vector<String> hang=new Vector<String>();
        hang.add("1");
        hang.add("学生1");
        rowData.add(hang);
        Vector<String> hang2=new Vector<String>();
        hang2.add("2");
        hang2.add("学生2");
        rowData.add(hang2);
        JTable jTable=new JTable(rowData,columnNames);
        this.add(jTable);
        this.setBounds(0, 0, 600, 400);
        this.setVisible(true);
        
    }
    
    
     public static void main(String[] args){
         JTableFrameTest myFrame=new JTableFrameTest("图形用户界面编程:JTable测试");
         
     }

    
}
